#include "RotationTest.h"
#include "KeyboardManager.h"
#include "MatrixHelper.h"

RotationTest::RotationTest()
{
	m_fYaw = 0;
}

RotationTest::~RotationTest()
{
}

void RotationTest::Update(float elapsedTime)
{
	if(KeyboardManager::GetInstance()->IsKeyDown('A'))
	{
		m_fYaw -= elapsedTime;
	}
	if(KeyboardManager::GetInstance()->IsKeyDown('D'))
	{
		m_fYaw += elapsedTime;
	}

	Quaternion rotation;

	rotation = Quaternion::CreateFromAxisAngle(Vector3f::Up, m_fYaw);

	SetRotation(rotation);

	if(KeyboardManager::GetInstance()->IsKeyDown('W'))
	{
		Matrix world;
		Vector3f forward;

		MatrixHelper::SetRotation(world, rotation);
		MatrixHelper::GetForward(world, forward);

		SetPosition(GetPosition() + forward * elapsedTime * 128.0f);
	}
}